
<link rel="stylesheet" href="/old_styles.css" type="text/css">
<?
$params[sid]=$sid;
$params[action]="view_groups";

$add_aff_url="$baseURL/$webDIR/payments/?".encode_params($params);
$add_group_url="$baseURL/$webDIR/payments/?".encode_params($params);
$remove_aff_url="$baseURL/$webDIR/payments/?".encode_params($params);
$remove_group_url="$baseURL/$webDIR/payments/?".encode_params($params);
$res=get_group_details($res_id);
while(list($k,$v)=each($res)){
	while(list($kk,$vv)=each($v)) if(!$vv) $v[$kk]="~";
	if($v[child_id]==$res_id){ 
		$group=$v;
	}else if($v[link_type]=='union'){
		$data[table_1].="
				<form method=post action='$remove_group_url'>
				<input type=hidden name='child_id' value='$v[child_id]'>
				<input type=hidden name=subaction value='remove'>
				<input type=hidden name=type value='union'>
				<input type=hidden name='parent_id' value='$res_id'>
				<tr>
				<td>$v[reseller]</td>
				<td>$v[firstname]</td>
				<td>$v[lastname]</td>
				<td>$v[email]</td>
				<td>$v[country]</td>
				<td>$v[state]</td>
				<td>$v[address1] | $v[address2]</td>
				<td><input type=submit value='Remove'></td>
				</tr>
				</form>";
	}else if($v[link_type]=='affiliate'){
		$data[table_2].="
				<form method=post action='$remove_aff_url'>
				<input type=hidden name='child_id' value='$v[child_id]'>
				<input type=hidden name=subaction value='remove'>
				<input type=hidden name=type value='affiliate'>
				<input type=hidden name='parent_id' value='$res_id'>
				<tr>
				<td>$v[child_id]</td>
				<td>$v[reseller]</td>
				<td>$v[firstname]</td>
				<td>$v[lastname]</td>
				<td>$v[email]</td>
				<td>$v[country]</td>
				<td>$v[state]</td>
				<td>$v[address1] | $v[address2]</td>
				<td><input type=submit value='Remove'></td>
				</tr>
				</form>";
	}
}
$res2=get_reseller_referer($res_id);
//print_r ($res2);

?>
<h2>Group main reseller: <?=$group[reseller]?></h2>
<table>
<tr>
	<th><?=$resellername?></th>
</tr>
<tr><th><?if($errorMsg) echo "$errorMsg"?></th></tr>
<tr><td>

<table class='bTable' cellspacing=0>
<tr>
	<th colspan=10>People who are in this payment group</th>
</tr>
<tr>
	<th>Groupmate</th>
	<TH>First name: </TH>
	<TH>Last name: </TH>
	<th>E-mail:</th>
	<TH>Country: </TH>
	<th>State</th>
	<th>Address:</th>
	<th>~</th>
</tr>
<?=$data[table_1];?>
</table>
</form>

<form method=post action='<?$add_group_url?>'>
<input type=hidden name=subaction value='add'>
<input type=hidden name=type value='union'>
<input type=hidden name='parent_id' value="<?=$group[id]?>">
<table><tr><th align=left>Reseller ID:(ID from reseller system)<br><input type=text name='child_id'>&nbsp;<input type='submit' value='ADD Group Member'></th></tr></table>
</form>


<form method=post action='<?$remove_aff_url?>'>
<input type=hidden name=subaction value='remove'>
<input type=hidden name=type value='affiliate'>
<input type=hidden name='parent_id' value="<?=$group[id]?>">
<table class='bTable' cellspacing=0>
<tr>
	<th colspan=10> People who are refered by this reseller</th>
</tr>
<tr>
	<th>id</th>
	<th>Affiliate</th>
	<TH>First name: </TH>
	<TH>Last name: </TH>
	<th>E-mail:</th>
	<TH>Country: </TH>
	<th>State</th>
	<th>Address:</th>
	<th>~</th>
</tr>
<?=$data[table_2];?>
</table>
</form>

<form method=post action='<?$add_aff_url?>'>
<input type=hidden name=subaction value='add'>
<input type=hidden name=type value='affiliate'>
<input type=hidden name='parent_id' value="<?=$group[id]?>">
<table><tr><th align=left>Affiliate id:(ID from reseller system)<br><input type=text name='child_id'>&nbsp;<input type='submit' value='ADD Affiliate'></th></tr></table>
</form>


<?if(is_array($res2)){?>
<table  class='bTable' cellspacing=0>
<tr><th colspan=10>Referers and Group of the reseller: (Link Type-union shows primery reseller of the payment group Linkt Type - affiliate shows reseller who has referred this reseller)</th></tr>
<tr>
    <th>Parent:</th>
	<th>Link Type:</th>
    <TH>First name: </TH>
    <TH>Last name: </TH>
    <th>E-mail:</th>
    <TH>Country: </TH>
    <th>State</th>
    <th>Address:</th>
</tr>
<?foreach($res2 as $r2){?>
<tr>
				<td><?=$r2[reseller]?></td>
				<td><?=$r2[link_type]?></td>
                <td><?=$r2[firstname]?></td>
                <td><?=$r2[lastname]?></td>
                <td><?=$r2[email]?></td>
                <td><?=$r2[country]?></td>
                <td><?=$r2[state]?></td>
      			<td><?=$r2[address1]?> |<?=$res2[address2]?></td>
</tr>
<?}?>
</table>
<?}?>
